package com.atguigu.tingshu.order.enumeration;

import com.atguigu.tingshu.common.constant.SystemConstant;

public enum OrderStatusEnum {

    //定义枚举类  枚举类虚需要无参或者有参方法
    ORDER_STATUS_UNPAID(SystemConstant.ORDER_STATUS_UNPAID,"未支付"),
    ORDER_STATUS_PAID(SystemConstant.ORDER_STATUS_PAID,"已支付"),
    ORDER_STATUS_CANCEL(SystemConstant.ORDER_STATUS_CANCEL,"没钱了,取消了");


    //定义成员变量
    private String orderstatus;
    private String orderstatusName;

    private   OrderStatusEnum(String orderstatus, String orderstatusName) {
        this.orderstatus = orderstatus;
        this.orderstatusName = orderstatusName;
    }


    public  static String getOrderStatusName(String orderstatus) {
        //首先获取枚举类的所有枚举
        OrderStatusEnum[] orderStatusEnum = OrderStatusEnum.values();
        for (OrderStatusEnum statusEnum : orderStatusEnum) {
            String status = statusEnum.orderstatus;
            if(status.equals(orderstatus)){
                return  statusEnum.orderstatusName;
            }
        }
        return  null;
    }
}
